package org.outlook.crawler.database.impl;

import java.util.List;
import java.util.Map;

import org.outlook.crawler.client.domain.Content;
import org.outlook.crawler.client.domain.ErrorReport;
import org.outlook.crawler.client.domain.Keyword;
import org.outlook.crawler.client.domain.Resource;
import org.outlook.crawler.client.domain.Source;
import org.outlook.crawler.client.pojo.ErrorType;
import org.outlook.crawler.database.CrawlerDataSource;
import org.outlook.crawler.database.DatabaseService;


public class CrawlerDataSourceImpl implements CrawlerDataSource {
	
	private DatabaseService databaseService;

	public void setDatabaseService(DatabaseService databaseService) {
		this.databaseService = databaseService;
	}

	@Override
	public void deleteContentByKeywordAndSourceId(Keyword keyword) {
		databaseService.delete(keyword.getKeyword());
	}

	@Override
	public void deleteContentsAndKeywordByKeywordId(Long keywordId) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public List<Content> getContentByKeyword(Keyword keyword) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Content> getContentBykeywordAndSourceId(String keyword,
			long sourceId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Map<String, String>> getContentsAndGenerateMap(Keyword keyword) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ErrorReport getErrorReport(String keyword, long sourceId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Keyword getKeywordBySourceId(String keyword, long sourceId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Keyword getKeywordFresh(String keyword, long sourceId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Source getSourceById(long sourceId) {
		Object object = databaseService.get(sourceId);
		if(object != null)
			return (Source) object;
		return null;
	}

	@Override
	public List<Resource> getSources() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void recordError(String keyword, long id, ErrorType errorType) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void saveContent(Content Content, Keyword keyword) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void saveKeyword(String keyword, Long sourceId) {
		Keyword keywordObject = new Keyword();
		keywordObject.setKeyword(keyword);
		keywordObject.setSource(getSourceById(sourceId));
		databaseService.put(keyword, sourceId);
	}

	@Override
	public void saveKeywordAndContent(String keyword, long sourceId,
			List<Content> contentList) {
		// TODO Auto-generated method stub
		
	}

}
